package com.tepth.remote.control.delegate.apply.notify;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;

import com.tepth.remote.control.R;
import com.tepth.remote.control.R2;
import com.tepth.remote.control.delegate.BasePermissionCheckerDelegate;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Description:
 *
 * @author Hequn.Lee
 * @date 2018/11/23
 */
public class NotifyDelegate extends BasePermissionCheckerDelegate {

    private static final String TYPE = "type";
    private static final String CONTEXT = "context";

    @BindView(R2.id.icon_toolbar_title)
    AppCompatTextView toolbarTitle = null;
    @BindView(R2.id.notification_title)
    AppCompatTextView textTitle = null;
    @BindView(R2.id.notification_context)
    AppCompatTextView textContext = null;

    public static NotifyDelegate create(int type, String context) {
        final NotifyDelegate contentDelegate = new NotifyDelegate();
        final Bundle bundle = new Bundle();
        bundle.putInt(TYPE, type);
        bundle.putString(CONTEXT, context);
        contentDelegate.setArguments(bundle);
        return contentDelegate;
    }

    @OnClick({R2.id.icon_toolbar_back, R2.id.linear_notification_close})
    void onBack() {
        pop();
    }

    @Override
    public Object setLayout() {
        return R.layout.delegate_notification;
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        toolbarTitle.setText("通知详情");
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View rootView) {
        final Bundle bundle = getArguments();
        if (bundle != null) {
            final int type = bundle.getInt(TYPE);
            switch (type) {
                case 2:
                    textTitle.setText("回复通知详情");
                    break;
                case 3:
                    textTitle.setText("平台通知详情");
                    break;
                case 1:
                    textTitle.setText("请假审批详情");
                    break;
                default:
                    break;
            }
            final String context = bundle.getString(CONTEXT);
            textContext.setText(context);
        }
    }
}
